<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - Bootstrap Table</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="/admin/favicon.ico"> 
    <link href="/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">

    <!-- <link href="/admin/css/plugins/iCheck/custom.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/chosen/chosen.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/cropper/cropper.min.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/switchery/switchery.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet"> -->

    <!-- <link href="/admin/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet"> -->
    <!-- <link href="/admin/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet"> -->

    <link href="/admin/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">

    <!-- <link href="/admin/css/plugins/clockpicker/clockpicker.css" rel="stylesheet"> -->

    <link href="/admin/css/animate.css" rel="stylesheet">
    <link href="/admin/css/style.css?v=4.1.0" rel="stylesheet">
    

</head>

<body class="">
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- <div class="ibox-content"> -->
            <!-- <div class="row row-lg"> -->
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content" style="border:0">
                            <form action="/admin/bkuser/bkuser_insert" method="post" class="form-horizontal m-t" id="signupForm" onsubmit="return false">
                                <!-- <input type="hidden" name="created_at" value="{{time()}}"> -->
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">登录名：</label>
                                    <div class="col-sm-8">
                                        <input id="username" name="username" class="form-control" type="text" value="">
                                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 将会成为您唯一的登入名</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">手机：</label>
                                    <div class="col-sm-8">
                                        <input id="tel" name="tel" class="form-control" type="text">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">E-mail：</label>
                                    <div class="col-sm-8">
                                        <input id="email" name="email" class="form-control" type="email">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">角色：</label>
                                    <div class="col-sm-8">
                                        <input id="role" name="role" class="form-control" type="text" readonly value="普通管理员">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">密码：</label>
                                    <div class="col-sm-8">
                                        <input id="password" name="password" class="form-control" type="password">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">确认密码：</label>
                                    <div class="col-sm-8">
                                        <input id="confirm_password" name="confirm_password" class="form-control" type="password">
                                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-8 col-sm-offset-3">
                                        <button class="btn btn-primary" id="add" type="submit">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            <!-- </div> -->
        <!-- </div> -->
    </div>



    <!-- 全局js -->
    <script src="/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/admin/js/layer.js"></script>

    <!-- 自定义js -->
    <script src="/admin/js/content.js?v=1.0.0"></script>


    <!-- Bootstrap table -->
    <script src="/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="/admin/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="/admin/js/plugins/validate/messages_zh.min.js"></script>

    <!-- <script src="/admin/js/demo/form-validate-demo.js"></script> -->

    <!-- Peity -->
    <script src="/admin/js/demo/bootstrap-table-demo.js"></script>

    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <!--统计代码，可删除-->
    <script>
        
        // $('form').submit().done(function(){
        //     var index = parent.layer.getFrameIndex(window.name);
        //     parent.layer.close(index);
        // })
        
    </script>

    <script>
        $.validator.setDefaults({
            highlight: function (element) {
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
            },
            success: function (element) {
                element.closest('.form-group').removeClass('has-error').addClass('has-success');
            },
            errorElement: "span",
            errorPlacement: function (error, element) {
                if (element.is(":radio") || element.is(":checkbox")) {
                    error.appendTo(element.parent().parent().parent());
                } else {
                    error.appendTo(element.parent());
                }
            },
            errorClass: "help-block m-b-none",
            validClass: "help-block m-b-none"
        });
        jQuery.validator.addMethod("isTel", function(value, element) {   
            var tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
            return this.optional(element) || (tel.test(value));
        }, "请正确填写您的手机号码");
        $().ready(function () {
            // validate the comment form when it is submitted
            $("#commentForm").validate();

            // validate signup form on keyup and submit
            var icon = "<i class='fa fa-times-circle'></i> ";
            $("#signupForm").validate({
                rules: {
                    username: {
                        required: true,
                        minlength: 2,
                        remote: "/admin/validate/usernamerepeat"
                    },
                    password: {
                        required: true,
                        minlength: 5
                    },
                    confirm_password: {
                        required: true,
                        minlength: 5,
                        equalTo: "#password"
                    },
                    email: {
                        required: true,
                        email: true
                    },
                    tel: {
                        required: true,
                        isTel: true,
                        remote: "/admin/validate/telrepeat"
                    }
                },
                messages: {
                    username: {
                        required: icon + "请输入您的用户名",
                        remote: "用户名已存在",
                        minlength: icon + "用户名必须两个字符以上"
                    },
                    password: {
                        required: icon + "请输入您的密码",
                        minlength: icon + "密码必须5个字符以上"
                    },
                    confirm_password: {
                        required: icon + "请再次输入密码",
                        minlength: icon + "密码必须5个字符以上",
                        equalTo: icon + "两次输入的密码不一致"
                    },
                    email: icon + "请输入您的E-mail",
                    tel: {
                        required: icon + "请输入您的手机号",
                        remote: "该手机号已被注册"
                    }
                },
                submitHandler:function(){
                    // $('#add').click(function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        // $("#signupForm").validate({
                            // submitHandler:function(){
                                $.ajax({
                                url:'/admin/bkuser/bkuser_insert',
                                type:'POST',
                                cache:false,
                                data:$('#signupForm').serialize(),
                                success:function(data){
                                    console.log(data);
                                    // window.parent.location.reload();
                                    if(data==1){
                                        layer.msg('添加成功',{'icon':1});
                                    }else{
                                        layer.msg('添加失败',{'icon':2});
                                    }
                                    setTimeout(function(){
                                        parent.layer.close(index);
                                    },1000);
                                }
                                }).done(function(){
                                    window.parent.location.reload();
                                }).fail(function(data){
                                    console.log(data);
                                    layer.msg('请正确填写信息');
                                })
                            // },
                        // });
                    // })
                }
            });
        });
    </script>

</body>

</html>
